/*
 *   Copyright 2021 zzh
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 *
 */

package com.aduib.boot.common.SPI;

import com.aduib.boot.common.SPI.metadata.ConstructorMetaData;
import com.aduib.boot.common.SPI.metadata.FieldMetaData;
import com.aduib.boot.common.SPI.metadata.MethodMetaData;

import java.util.List;

/**
 * @description: SPIDefinition
 * @author: zzh
 * @date: 2021/9/18 15:48
 */
public interface SPIDefinition {
  /**
   * 获取SPI类的文件路径
   *
   * @return
   */
  String getFilePath();

  void setFilePath(String filePath);

  /**
   * 获取SPI名称
   *
   * @return
   */
  String getName();

  void setName(String name);

  /**
   * 获取SPI的类加载器
   *
   * @return
   */
  default ClassLoader getClassLoader() {
    return getSPIClass().getClassLoader();
  }

  /**
   * 父类
   * @return
   */
  Class<?> getSuperClass();

  /**
   * 获取接口数组
   * @return
   */
  Class<?>[] getInterfaces();
  /**
   * 获取SPI的类型
   *
   * @return
   */
  Class<?> getSPIClass();

  void setSPIClass(Class<?> clazz);

  /**
   * 获取SPI的角色
   *
   * @return
   */
  default SPIRole getRole() {
    return SPIRole.NORMAL_SPI;
  }

  List<ConstructorMetaData> getConstructorMetaDataList();

  List<FieldMetaData> getFieldMetaDataList();

  List<MethodMetaData> getMethodMetaDataList();
  /** SPI角色 */
  enum SPIRole {
    /** 内置SPI */
    INTERNAL_SPI,
    /** 正常SPI */
    NORMAL_SPI,
    /** 正常services */
    NORMAL_SERVICES
  }
}
